home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume16 / ms_sh-1.6 / patch01 next >
Encoding:
Internet Message Format  |  1991-01-19  |  40.5 KB

  1. From: istewart@datlog.co.uk (Ian Stewartson)
  2. Newsgroups: comp.sources.misc
  3. Subject: v16i078:  MSDOS Shell (sh) Implementation 1.6.4, Patch01/02
  4. Message-ID: <1991Jan16.195036.11473@sparky.IMD.Sterling.COM>
  5. Date: 16 Jan 91 19:50:36 GMT
  6. Approved: kent@sparky.imd.sterling.com
  7. X-Checksum-Snefru: 73adc354 f7a3fd6f c609dbbb 9f096918
  8.  
  9. Submitted-by: istewart@datlog.co.uk (Ian Stewartson)
  10. Posting-number: Volume 16, Issue 78
  11. Archive-name: ms_sh-1.6/patch01
  12. Patch-To: ms_sh-1.6: Volume 12, Issue 19-26
  13.  
  14. 1.6.4 of the MSDOS Shell.  Unfortunately, I'm tied up with real work
  15. at the moment, so this is likely to be the last upgrade for a couple
  16. of months.
  17.  
  18. It fixes one or two bugs and provides some new feature from the
  19. Korn/POSIX shell (see release notes).
  20.  
  21. Regards,
  22.  
  23. Ian Stewartson
  24. Data Logic
  25.  
  26. -------
  27. #!/bin/sh
  28. # This is a shell archive (shar 3.46)
  29. # made 12/24/1990 18:01 UTC by istewart@dlvax2
  30. # Source directory /usr/proj1/ssd/istewart/src/shell
  31. #
  32. # existing files will NOT be overwritten unless -c is specified
  33. #
  34. # This is part 1 of a multipart archive                                    
  35. # do not concatenate these parts, unpack them in order with /bin/sh        
  36. #
  37. # This shar contains:
  38. # length  mode       name
  39. # ------ ---------- ------------------------------------------
  40. #  63614 -rw-r--r-- Patch1.6.4
  41. #
  42. if test -r _shar_seq_.tmp; then
  43.     echo 'Must unpack archives in sequence!'
  44.     echo Please unpack part `cat _shar_seq_.tmp` next
  45.     exit 1
  46. fi
  47. # ============= Patch1.6.4 ==============
  48. if test -f 'Patch1.6.4' -a X"$1" != X"-c"; then
  49.     echo 'x - skipping Patch1.6.4 (File already exists)'
  50.     rm -f _shar_wnt_.tmp
  51. else
  52. > _shar_wnt_.tmp
  53. echo 'x - extracting Patch1.6.4 (Text)'
  54. sed 's/^X//' << 'SHAR_EOF' > 'Patch1.6.4' &&
  55. Index: Notes1.6
  56. *** ../sh16.3/Notes1.6    Fri Aug 17 21:29:59 1990
  57. --- Notes1.6    Tue Nov  6 20:47:31 1990
  58. ***************
  59. *** 1,4 ****
  60. ! Version 1.6.3 Release Notes:
  61. X  
  62. X  Note: Release 1.6.1 did occur to comp.ibm.pc.binaries.  However, the
  63. X  transmission was corrupt and by the time I was notified (the moderator having
  64. --- 1,4 ----
  65. ! Version 1.6.4 Release Notes:
  66. X  
  67. X  Note: Release 1.6.1 did occur to comp.ibm.pc.binaries.  However, the
  68. X  transmission was corrupt and by the time I was notified (the moderator having
  69. ***************
  70. *** 41,47 ****
  71. X      The code has been fixed to cope with DOS 4.
  72. X    21.    A bug in the processing of functions has been fixed which caused
  73. X      the shell to crash or hang has been fixed.
  74. X  The following enhancements have been made:
  75. X  
  76. X     1.   /dev/tty and /dev/null are mapped to /dev/con and /dev/nul internally
  77. --- 41,48 ----
  78. X      The code has been fixed to cope with DOS 4.
  79. X    21.    A bug in the processing of functions has been fixed which caused
  80. X      the shell to crash or hang has been fixed.
  81. !   22.    A bug in the function code that caused case functions to hang
  82. !     has been fixed.
  83. X  The following enhancements have been made:
  84. X  
  85. X     1.   /dev/tty and /dev/null are mapped to /dev/con and /dev/nul internally
  86. ***************
  87. *** 78,83 ****
  88. --- 79,87 ----
  89. X     20.  The POSIX variable substitution command ${#name} to give the
  90. X      string length has been implemented.
  91. X     21.  The POSIX I/O option <> has been implemented.
  92. +    22.  The POSIX I/O options ${#*%} and ~ have been implemented.
  93. +    23.  The builtin command command has been implemented.
  94. +    24.  The source for stdargv.c has been modified to work under OS/2
  95. X  
  96. X  The following enhancements/bugs remain outstanding:
  97. X  
  98. ***************
  99. *** 93,98 ****
  100. --- 97,108 ----
  101. X      processing of escape characters.  The shell uses the 8-bit to
  102. X      mark escaped characters (Release 1.7).
  103. X      
  104. +     3.  Interrupting a disk swap at the wrong time may cause the shell to
  105. +     hang.  I've tried disabling Control-Break during disk read/writes
  106. +     but this only causes the shell to hang on re-load every time in
  107. +     some environments.  In the next release, I'm going to put in some
  108. +     checks and issue re-read/writes when necessary.
  109. +     
  110. X  Thanks are due to
  111. X  
  112. X      Greg Yachuk 
  113. ***************
  114. *** 101,106 ****
  115. --- 111,117 ----
  116. X      John B Thiel 
  117. X      Harry McGavran 
  118. X      Bill Davidsen
  119. +     Richard J Reiner
  120. X  
  121. X  for their comments, fixes, tolerance etc in testing release 1.6
  122. X  
  123. Index: lib/stdargv.c
  124. *** ../sh16.3/lib/stdargv.c    Fri Mar  2 11:34:58 1990
  125. --- lib/stdargv.c    Tue Nov  6 20:52:05 1990
  126. ***************
  127. *** 18,25 ****
  128. X   *            This function replaces the standard MS-DOS command
  129. X   *            line processing function (_setargv in stdargv.obj).
  130. X   *
  131. !  *  CALLING SEQUENCE:    The following calling sequences are used:
  132. X   *
  133. X   *            void    _setargv ();
  134. X   *
  135. X   *  ERROR MESSAGES:    Out of memory
  136. --- 18,27 ----
  137. X   *            This function replaces the standard MS-DOS command
  138. X   *            line processing function (_setargv in stdargv.obj).
  139. X   *
  140. !  *            Support for OS2 added.  Compile with -DOS2
  141. X   *
  142. +  *  CALLING SEQUENCE:    The following calling sequences are used:
  143. +  *
  144. X   *            void    _setargv ();
  145. X   *
  146. X   *  ERROR MESSAGES:    Out of memory
  147. ***************
  148. *** 32,45 ****
  149. X  #include <stdio.h>            /* Standard I/O delarations         */
  150. X  #include <stdlib.h>            /* Standard library functions       */
  151. X  #include <errno.h>            /* Error number declarations        */
  152. X  #include <dos.h>            /* DOS functions declarations       */
  153. X  #include <bios.h>            /* BIOS functions declarations      */
  154. X  #include <ctype.h>            /* Character type declarations      */
  155. X  #include <string.h>            /* String library functions         */
  156. X  #include <limits.h>            /* String library functions         */
  157. X  #include <fcntl.h>            /* File Control Declarations        */
  158. - #include <io.h>                /* Input/Output Declarations        */
  159. X  #include <dirent.h>            /* Direction I/O functions        */
  160. X  
  161. X  /*
  162. X   *  DATA DEFINITIONS:
  163. --- 34,51 ----
  164. X  #include <stdio.h>            /* Standard I/O delarations         */
  165. X  #include <stdlib.h>            /* Standard library functions       */
  166. X  #include <errno.h>            /* Error number declarations        */
  167. + #ifdef OS2
  168. + #include <os2.h>            /* OS2 functions declarations       */
  169. + #else
  170. X  #include <dos.h>            /* DOS functions declarations       */
  171. X  #include <bios.h>            /* BIOS functions declarations      */
  172. + #endif
  173. X  #include <ctype.h>            /* Character type declarations      */
  174. X  #include <string.h>            /* String library functions         */
  175. X  #include <limits.h>            /* String library functions         */
  176. X  #include <fcntl.h>            /* File Control Declarations        */
  177. X  #include <dirent.h>            /* Direction I/O functions        */
  178. + #include <unistd.h>
  179. X  
  180. X  /*
  181. X   *  DATA DEFINITIONS:
  182. ***************
  183. *** 65,76 ****
  184. --- 71,90 ----
  185. X  static void    ex_fatal (int, char *, char *);    /* Fatal error processing*/
  186. X  static char    *ex_environment (char *);    /* Process environment    */
  187. X  static char    *_ex_multi_drive (char *);    /* Check for multidrive    */
  188. + static int    N_floppy_disks (void);
  189. X  static char    *ex_nomem = "%s: %s\n";
  190. X  
  191. X  extern char far    *_pgmptr;         /* Program name            */
  192. X  extern char    **__argv;         /* Current argument address    */
  193. X  extern int    __argc;         /* Current argument count    */
  194. X  
  195. + #ifdef OS2
  196. + static void     _dos_setdrive (unsigned int, unsigned int *);
  197. + static void     _dos_getdrive (unsigned int *);
  198. + extern ushort    _aenvseg;        /* Environment seg        */
  199. + extern ushort    _acmdln;        /* Command line offset        */
  200. + #endif
  201. X  /*
  202. X   *  MODULE ABSTRACT: _setargv
  203. X   *
  204. ***************
  205. *** 79,92 ****
  206. X  
  207. X  void    _setargv ()
  208. X  {
  209. X                      /* Set up pointer to command line */
  210. X      char far        *argvp = (char far *)((((long)_psp) << 16) + 0x081L);
  211. X      unsigned int    envs = *(int far *)((((long)_psp) << 16) + 0x02cL);
  212. X      char far        *s;         /* Temporary string pointer        */
  213. ! #ifndef M_I86LM
  214. X      char        buf[MAX_LINE];    /* Temporary space        */
  215. X      char        *cp;
  216. ! #endif
  217. X  
  218. X  /* Command line can be null or 0x0d terminated - convert to null */
  219. X  
  220. --- 93,131 ----
  221. X  
  222. X  void    _setargv ()
  223. X  {
  224. + #ifdef OS2
  225. +     char far        *argvp = (char far *)((((long)_aenvseg) << 16));
  226. +     ushort        off = _acmdln;
  227. +     while (--off)
  228. +     {
  229. +     if (argvp[off - 1] == 0)
  230. +          break;
  231. +     }
  232. + /* Add program name */
  233. +     _pgmptr =  &argvp[off];
  234. +     if (argvp[_acmdln] == 0)
  235. +     ex_add_arg (ex_tounix (_pgmptr));    /* Add the program name    */
  236. +     else
  237. +     {
  238. +     argvp += _acmdln;
  239. +     ex_add_arg (ex_tounix (argvp));        /* Add the program name    */
  240. +     argvp += strlen (argvp) + 1;
  241. +     exp_line (argvp);
  242. +     }
  243. + #else
  244. X                      /* Set up pointer to command line */
  245. X      char far        *argvp = (char far *)((((long)_psp) << 16) + 0x081L);
  246. X      unsigned int    envs = *(int far *)((((long)_psp) << 16) + 0x02cL);
  247. X      char far        *s;         /* Temporary string pointer        */
  248. ! #  ifndef M_I86LM
  249. X      char        buf[MAX_LINE];    /* Temporary space        */
  250. X      char        *cp;
  251. ! #  endif
  252. X  
  253. X  /* Command line can be null or 0x0d terminated - convert to null */
  254. X  
  255. ***************
  256. *** 123,129 ****
  257. X  
  258. X      _pgmptr = s;
  259. X  
  260. ! #ifndef M_I86LM
  261. X      cp = buf;
  262. X      while (*(cp++) = *(s++));
  263. X  
  264. --- 162,168 ----
  265. X  
  266. X      _pgmptr = s;
  267. X  
  268. ! #  ifndef M_I86LM
  269. X      cp = buf;
  270. X      while (*(cp++) = *(s++));
  271. X  
  272. ***************
  273. *** 134,142 ****
  274. X      while (*(cp++) = *(s++));
  275. X  
  276. X      exp_line (buf);
  277. ! #else
  278. X      ex_add_arg (ex_tounix (s));        /* Add the program name        */
  279. X      exp_line (argvp);
  280. X  #endif
  281. X  
  282. X      ex_add_arg ((char *)NULL);
  283. --- 173,182 ----
  284. X      while (*(cp++) = *(s++));
  285. X  
  286. X      exp_line (buf);
  287. ! #  else
  288. X      ex_add_arg (ex_tounix (s));        /* Add the program name        */
  289. X      exp_line (argvp);
  290. + #  endif
  291. X  #endif
  292. X  
  293. X      ex_add_arg ((char *)NULL);
  294. ***************
  295. *** 262,268 ****
  296. X  
  297. X  /* Check to see if the second diskette drive is really there */
  298. X  
  299. !         if (((_bios_equiplist () & 0x00c0) == 0x0000) && (s_drive == 2))
  300. X          continue;
  301. X  
  302. X  /* If the drive exists and is in our list - process it */
  303. --- 302,308 ----
  304. X  
  305. X  /* Check to see if the second diskette drive is really there */
  306. X  
  307. !         if ((N_floppy_disks () < 2) && (s_drive == 2))
  308. X          continue;
  309. X  
  310. X  /* If the drive exists and is in our list - process it */
  311. ***************
  312. *** 619,623 ****
  313. --- 659,703 ----
  314. X      }
  315. X  
  316. X      return (*prefix && (*(prefix + 1) == ':')) ? prefix + 1 : (char *)NULL;
  317. + }
  318. + /* Some OS/2 functions to emulate the DOS functions */
  319. + #ifdef OS2
  320. + static void     _dos_getdrive (cdp)
  321. + unsigned int    *cdp;
  322. + {
  323. +     USHORT    cdr;
  324. +     ULONG    ndr;
  325. +     DosQCurDisk((PUSHORT)&cdr, (PULONG) &ndr);
  326. +     *cdp = (unsigned int)cdr;
  327. + }
  328. + static void     _dos_setdrive (cdr, ndp)
  329. + unsigned int    cdr;
  330. + unsigned int    *ndp;
  331. + {
  332. +     USHORT    dummy;
  333. +     ULONG    ndr;
  334. +     DosQCurDisk((PUSHORT)&dummy, (PULONG) &ndr);
  335. +     *ndp = (unsigned int)ndr;
  336. +     DosSelectDisk ((USHORT)cdr);
  337. + }
  338. + #endif
  339. + /* Return the number of floppy disks */
  340. + static    int    N_floppy_disks ()
  341. + {
  342. + #ifdef OS2
  343. +     BYTE    nflop = 1;
  344. +     DosDevConfig (&nflop, 2, 0);
  345. +     return nflop;
  346. + #else
  347. +     return ((_bios_equiplist () & 0x00c0) >> 6) + 1;
  348. + #endif
  349. X  }
  350. X  #endif
  351. Index: sh.1
  352. Prereq: 1.11
  353. *** ../sh16.3/sh.1    Fri Aug 17 21:31:41 1990
  354. --- sh.1    Tue Nov  6 20:11:17 1990
  355. ***************
  356. *** 14,22 ****
  357. X  .\" 2.  The sources (or parts thereof) or objects generated from the sources
  358. X  .\"     (or parts of sources) cannot be sold under any circumstances.
  359. X  .\"
  360. ! .\"    $Header: C:/SRC/SHELL/RCS/sh.1 1.11 90/08/14 23:17:25 Ian_Stewartson Exp $
  361. X  .\"
  362. X  .\"    $Log:    sh.1 $
  363. X  .\"    Revision 1.11  90/08/14  23:17:25  Ian_Stewartson
  364. X  .\"    Add IO read/write open
  365. X  .\"    
  366. --- 14,26 ----
  367. X  .\" 2.  The sources (or parts thereof) or objects generated from the sources
  368. X  .\"     (or parts of sources) cannot be sold under any circumstances.
  369. X  .\"
  370. ! .\"    $Header: D:/SRC/SHELL/RCS/sh.1 1.12 90/11/06 20:08:46 Ian_Stewartson Exp $
  371. X  .\"
  372. X  .\"    $Log:    sh.1 $
  373. + .\"    Revision 1.12  90/11/06  20:08:46  Ian_Stewartson
  374. + .\"    Add POSIX options {#%*} and ~
  375. + .\"    Add builtin command
  376. + .\"    
  377. X  .\"    Revision 1.11  90/08/14  23:17:25  Ian_Stewartson
  378. X  .\"    Add IO read/write open
  379. X  .\"    
  380. ***************
  381. *** 163,172 ****
  382. X  .SS Comments
  383. X  A word beginning with \fB#\fR causes that word and all the following
  384. X  characters up to a new-line to be ignored.
  385. X  .SS Command Substitution
  386. ! The standard output from a command enclosed in a pair of grave accents
  387. ! (\fB\(ga\(ga\fR) may be used as part or all of a word; trailing new-lines
  388. ! are removed.
  389. X  .SS Parameter Substitution
  390. X  The character \fB$\fR is used to introduce substitutable \fIparameters\fR.
  391. X  There are two types of parameters, positional and keyword.  If \fIparameter\fR
  392. --- 167,179 ----
  393. X  .SS Comments
  394. X  A word beginning with \fB#\fR causes that word and all the following
  395. X  characters up to a new-line to be ignored.
  396. + .SS Tilde Substitution
  397. + Each word is checked to see if it begins with an unquoted\fB~\fR.  If it is,
  398. + the \fB~\fR is replaced by the value of the \fBHOME\fR parameter.    
  399. X  .SS Command Substitution
  400. ! The standard output from a command enclosed in parenthesis preceded by a
  401. ! dollar sign (\fB$()\fR), or in a pair of grave accents (\fB\(ga\(ga\fR) may
  402. ! be used as part or all of a word; trailing new-lines are removed.
  403. X  .SS Parameter Substitution
  404. X  The character \fB$\fR is used to introduce substitutable \fIparameters\fR.
  405. X  There are two types of parameters, positional and keyword.  If \fIparameter\fR
  406. ***************
  407. *** 184,196 ****
  408. X  .PD 0
  409. X  .TP
  410. X  \fB${\fIparameter\fB}\fR
  411. ! The value, if any, of the parameter is substituted.  The braces are required
  412. ! only when \fIparameter\fR is followed by a letter, digit, or underscore that
  413. ! is not to be interpreted as part of its name.  If \fIparameter\fR is
  414. ! \fB*\fR or \fB@\fR, all the positional parameters, starting with \fB$1\fR,
  415. ! are substituted (separated by spaces).  Parameter \fB$0\fR is set from argument
  416. ! zero when the shell is invoked.
  417. X  .TP
  418. X  \fB${\fIparameter\fB:-\fIword\fB}\fR
  419. X  If \fIparameter\fR is set and is non-null, substitute its value; otherwise
  420. X  substitute \fIword\fR.
  421. --- 191,208 ----
  422. X  .PD 0
  423. X  .TP
  424. X  \fB${\fIparameter\fB}\fR
  425. ! The value, if any, of the \fIparameter\fR is substituted.  The braces are
  426. ! required only when \fIparameter\fR is followed by a letter, digit, or
  427. ! underscore that is not to be interpreted as part of its name.  If
  428. ! \fIparameter\fR is \fB*\fR or \fB@\fR, all the positional parameters, starting
  429. ! with \fB$1\fR, are substituted (separated by spaces).  Parameter \fB$0\fR is
  430. ! set from argument zero when the shell is invoked.
  431. X  .TP
  432. + \fB${#\fIparameter\fB}\fR
  433. + If \fIparameter\fR is \fB*\fR or \fB@\fR, the number of positional parameters
  434. + is substituted.  Otherwise, the length of the value of the \fIparameter\fR is
  435. + substituted.
  436. + .TP
  437. X  \fB${\fIparameter\fB:-\fIword\fB}\fR
  438. X  If \fIparameter\fR is set and is non-null, substitute its value; otherwise
  439. X  substitute \fIword\fR.
  440. ***************
  441. *** 208,213 ****
  442. --- 220,242 ----
  443. X  \fB${\fIparameter\fB:+\fIword\fB}\fR
  444. X  If \fIparameter\fR is set and is non-null, substitute \fIword\fR; otherwise
  445. X  substitute nothing.
  446. + .TP
  447. + \fB${\fIparameter\fB#\fIpattern\fB}\fR
  448. + \fB${\fIparameter\fB##\fIpattern\fB}\fR
  449. + If the Shell \fIpattern\fR matches the beginning of the value of
  450. + \fIparameter\fR, then the value of this substitution is the value of the
  451. + \fIparameter\fR with the matched portion deleted; otherwise the value of
  452. + this \fIparameter\fR is substituted.  In the first form the smallest matching
  453. + \fIpattern\fR is deleted and in the latter form the largest matching
  454. + \fIpattern\fR is deleted.
  455. + .TP
  456. + \fB${\fIparameter\fB%\fIpattern\fB}\fR
  457. + \fB${\fIparameter\fB%%\fIpattern\fB}\fR
  458. + If the Shell \fIpattern\fR matches the end of the value of \fIparameter\fR,
  459. + then the value of this substitution is the value of the \fIparameter\fR with
  460. + the matched portion deleted; otherwise the value of this \fIparameter\fR is
  461. + substituted.  In the first form the smallest matching \fIpattern\fR is deleted
  462. + and in the latter form the largest matching \fIpattern\fR is deleted.
  463. X  .PD
  464. X  .PP
  465. X  In the above, \fIword\fR is not evaluated unless it is to be used as the
  466. ***************
  467. *** 830,835 ****
  468. --- 859,886 ----
  469. X  Exit from the enclosing \fBfor\fR or \fBwhile\fR loop, if any.  If \fIn\fR is
  470. X  specified, break \fIn\fR levels.
  471. X  .TP
  472. + \fBbuiltin\fR \*(OK \fIargs\fR ... \*(CK
  473. + Force the selection of the \fBbuiltin\fR version of a command.  The builtin
  474. + shell command selected by the first \fIargs\fR value is executed with the
  475. + parameters defined by the remaining \fIargs\fRs.  If no arguments are given,
  476. + a list of all \fIbuiltin\fR commands is printed.
  477. + .sp
  478. + If the first argument is one of the following, the processing of the
  479. + builtin command in the following arguments are changed as indicated:
  480. + .RS
  481. + .TP
  482. + \fB-a\fR
  483. + Set the following builtin commands to use builtin version in preference to
  484. + any function or external versions.
  485. + .TP
  486. + \fB-d\fR
  487. + Set the following builtin commands to use the function or external version
  488. + in preference to the builtin version.
  489. + .TP
  490. + \fB-s\fR
  491. + Display the current status of the following builtin commands.
  492. + .RE
  493. + .TP
  494. X  \fBcontinue\fR \*(OK \fIn\fR \*(CK
  495. X  Resume the next iteration of the enclosing \fBfor\fR or \fBwhile\fR loop.  If
  496. X  \fIn\fR is specified, resume at the \fIn\fR-th enclosing loop.
  497. ***************
  498. *** 986,992 ****
  499. X  \fBmsdos\fR \*(OK \fIname\fR ... \*(CK
  500. X  The given \fIname\fRs are marked \fImsdos\fR format and if the \fB-m\fR flag
  501. X  is set, the values of the these \fIname\fRs are exported to child processes
  502. ! with any slashes in the value replaced by backslashes.
  503. X  .TP
  504. X  \fBpwd\fR
  505. X  Print the current working directory.  
  506. --- 1037,1044 ----
  507. X  \fBmsdos\fR \*(OK \fIname\fR ... \*(CK
  508. X  The given \fIname\fRs are marked \fImsdos\fR format and if the \fB-m\fR flag
  509. X  is set, the values of the these \fIname\fRs are exported to child processes
  510. ! with any slashes in the value replaced by backslashes.  If no arguments are
  511. ! given, a list of all \fImsdos\fR names is printed.
  512. X  .TP
  513. X  \fBpwd\fR
  514. X  Print the current working directory.  
  515. Index: shell/sh.h
  516. Prereq: 1.21
  517. *** ../sh16.3/shell/sh.h    Fri Aug 17 21:33:20 1990
  518. --- shell/sh.h    Tue Nov  6 19:18:37 1990
  519. ***************
  520. *** 13,21 ****
  521. X   * 2.  The sources (or parts thereof) or objects generated from the sources
  522. X   *     (or parts of sources) cannot be sold under any circumstances.
  523. X   *
  524. !  *    $Header: C:/SRC/SHELL/RCS/sh.h 1.21 90/08/14 23:54:44 MS_user Exp $
  525. X   *
  526. X   *    $Log:    sh.h $
  527. X   * Revision 1.21  90/08/14  23:54:44  MS_user
  528. X   * Add addition value to env structure
  529. X   * Add some new publics
  530. --- 13,27 ----
  531. X   * 2.  The sources (or parts thereof) or objects generated from the sources
  532. X   *     (or parts of sources) cannot be sold under any circumstances.
  533. X   *
  534. !  *    $Header: D:/SRC/SHELL/RCS/sh.h 1.23 90/09/19 15:29:54 Ian_Stewartson Exp $
  535. X   *
  536. X   *    $Log:    sh.h $
  537. +  * Revision 1.23  90/09/19  15:29:54  Ian_Stewartson
  538. +  * Allow builtin commands to selected/de-selected
  539. +  * 
  540. +  * Revision 1.22  90/08/24  21:53:13  Ian_Stewartson
  541. +  * Add support for POSIX macro command {x#y} and {x%y}
  542. +  * 
  543. X   * Revision 1.21  90/08/14  23:54:44  MS_user
  544. X   * Add addition value to env structure
  545. X   * Add some new publics
  546. ***************
  547. *** 85,91 ****
  548. X   * 
  549. X   */
  550. X  
  551. ! #define PATCHLEVEL    7
  552. X  #define    LINE_MAX    1000    /* Command line length            */
  553. X  #define HISTORY_MAX    100    /* History array length            */
  554. X                  /* Space for full file name        */
  555. --- 91,97 ----
  556. X   * 
  557. X   */
  558. X  
  559. ! #define PATCHLEVEL    8
  560. X  #define    LINE_MAX    1000    /* Command line length            */
  561. X  #define HISTORY_MAX    100    /* History array length            */
  562. X                  /* Space for full file name        */
  563. ***************
  564. *** 168,179 ****
  565. X  struct    builtin {
  566. X      char    *command;
  567. X      int        (*fn)(C_Op *);
  568. X  };
  569. X  
  570. X  /*
  571. !  * actions determining the environment of a process
  572. X   */
  573. X  
  574. X  #define    FEXEC        0x0001    /* execute without forking        */
  575. X  
  576. X  /* MSDOS Memory Control Block chain structure */
  577. --- 174,193 ----
  578. X  struct    builtin {
  579. X      char    *command;
  580. X      int        (*fn)(C_Op *);
  581. +     int        mode;
  582. X  };
  583. X  
  584. X  /*
  585. !  * Valid values of mode
  586. X   */
  587. X  
  588. + #define BLT_ALWAYS    0x0001    /* Always use builtin version        */
  589. + #define BLT_CURRENT    0x0002    /* Currently use builtin version    */
  590. + /*
  591. +  * actions determining the environment of a process
  592. +  */
  593. X  #define    FEXEC        0x0001    /* execute without forking        */
  594. X  
  595. X  /* MSDOS Memory Control Block chain structure */
  596. ***************
  597. *** 376,384 ****
  598. X                      /* depth            */
  599. X  
  600. X  /*
  601. !  * Variable list
  602. X   */
  603. X  
  604. X  typedef struct var {
  605. X      char        *value;        /* Value            */
  606. X      char        *name;        /* Name                */
  607. --- 390,407 ----
  608. X                      /* depth            */
  609. X  
  610. X  /*
  611. !  * Mode values for new gmatch 
  612. X   */
  613. X  
  614. + #define GM_ALL        0        /* Match full string        */
  615. + #define GM_SHORTEST    1        /* Shortest prefix/suffix    */
  616. + #define GM_LONGEST    2        /* Longest prefix/suffix    */
  617. + /*
  618. + /*
  619. +  * Variable list
  620. +  */
  621. X  typedef struct var {
  622. X      char        *value;        /* Value            */
  623. X      char        *name;        /* Name                */
  624. ***************
  625. *** 531,537 ****
  626. X  extern void    s_vstatus (Var_List *, int);
  627. X  extern bool    isassign (char *);
  628. X  extern bool    assign (char *, int);
  629. ! extern bool    gmatch (char *, char *, bool);
  630. X  extern char    *getcell (unsigned int);
  631. X  extern void    freecell (char *);
  632. X  extern void    freearea (int);
  633. --- 554,561 ----
  634. X  extern void    s_vstatus (Var_List *, int);
  635. X  extern bool    isassign (char *);
  636. X  extern bool    assign (char *, int);
  637. ! extern bool    gmatch (char *, char *, bool, char **, int);
  638. ! extern bool    gmatch_suffix (char *, char *, bool, char **, int);
  639. X  extern char    *getcell (unsigned int);
  640. X  extern void    freecell (char *);
  641. X  extern void    freearea (int);
  642. ***************
  643. *** 574,580 ****
  644. X  extern void    put_prompt (char *);
  645. X  extern bool    eqname (char *, char *);
  646. X  extern bool    any (char, char *);
  647. ! extern int    (*inbuilt (char *))();
  648. X  extern char    *path_append (char *, char *, char *);
  649. X  extern void    unset (char *, bool);
  650. X  extern int    S_open (bool, char *, int, ...);
  651. --- 598,604 ----
  652. X  extern void    put_prompt (char *);
  653. X  extern bool    eqname (char *, char *);
  654. X  extern bool    any (char, char *);
  655. ! extern int    (*inbuilt (char *, bool *))();
  656. X  extern char    *path_append (char *, char *, char *);
  657. X  extern void    unset (char *, bool);
  658. X  extern int    S_open (bool, char *, int, ...);
  659. Index: shell/sh0.asm
  660. Prereq: 1.10
  661. *** ../sh16.3/shell/sh0.asm    Fri Aug 17 21:33:41 1990
  662. --- shell/sh0.asm    Tue Nov  6 19:19:30 1990
  663. ***************
  664. *** 16,22 ****
  665. X  ; 2.  The sources (or parts thereof) or objects generated from the sources
  666. X  ;     (or parts of sources) cannot be sold under any circumstances.
  667. X  ;
  668. ! ;    $Header: C:/SRC/SHELL/RCS/sh0.asm 1.10 90/05/31 17:46:31 MS_user Exp $
  669. X  ;
  670. X  ;    $Log:    sh0.asm $
  671. X  ;    Revision 1.10  90/05/31  17:46:31  MS_user
  672. --- 16,22 ----
  673. X  ; 2.  The sources (or parts thereof) or objects generated from the sources
  674. X  ;     (or parts of sources) cannot be sold under any circumstances.
  675. X  ;
  676. ! ;    $Header: D:/SRC/SHELL/RCS/sh0.asm 1.10 90/05/31 17:46:31 MS_user Exp $
  677. X  ;
  678. X  ;    $Log:    sh0.asm $
  679. X  ;    Revision 1.10  90/05/31  17:46:31  MS_user
  680. Index: shell/sh1.c
  681. Prereq: 1.17
  682. *** ../sh16.3/shell/sh1.c    Fri Aug 17 21:32:33 1990
  683. --- shell/sh1.c    Tue Nov  6 19:20:30 1990
  684. ***************
  685. *** 13,77 ****
  686. X   * 2.  The sources (or parts thereof) or objects generated from the sources
  687. X   *     (or parts of sources) cannot be sold under any circumstances.
  688. X   *
  689. !  *    $Header: C:/SRC/SHELL/RCS/sh1.c 1.17 90/08/14 23:32:53 MS_user Exp $
  690. X   *
  691. X   *    $Log:    sh1.c $
  692. X   * Revision 1.17  90/08/14  23:32:53  MS_user
  693. X   * Fix memory bugs - Add malloc checking functions for debug
  694. X   * Make Convert_Backslashes public
  695. !  * 
  696. X   * Revision 1.16  90/05/31  09:48:06  MS_user
  697. X   * Implement partial write when swapping to disk
  698. X   * Add some signal lockouts to prevent corruption
  699. !  * 
  700. X   * Revision 1.15  90/05/15  21:08:59  MS_user
  701. X   * Restore original directory on exit
  702. !  * 
  703. X   * Revision 1.14  90/04/25  22:33:28  MS_user
  704. X   * Fix rsh check for PATH
  705. !  * 
  706. X   * Revision 1.13  90/04/25  09:18:12  MS_user
  707. X   * Change version message processing
  708. !  * 
  709. X   * Revision 1.12  90/04/04  11:32:12  MS_user
  710. X   * Change MAILPATH to use a semi-colon and not a colon for DOS
  711. !  * 
  712. X   * Revision 1.11  90/04/03  17:58:35  MS_user
  713. X   * Stop shell exit from lowest level CLI
  714. !  * 
  715. X   * Revision 1.10  90/03/27  20:24:49  MS_user
  716. X   * Fix problem with Interrupts not restoring std??? and clearing extended file
  717. !  * 
  718. X   * Revision 1.9  90/03/26  20:56:13  MS_user
  719. X   * Change I/O restore so that "exec >filename" works
  720. !  * 
  721. X   * Revision 1.8  90/03/26  04:30:14  MS_user
  722. X   * Remove original Interrupt 24 save address
  723. !  * 
  724. X   * Revision 1.7  90/03/12  20:16:22  MS_user
  725. X   * Save program name for Initialisation file processing
  726. !  * 
  727. X   * Revision 1.6  90/03/09  16:05:33  MS_user
  728. X   * Add build file name function and change the profile check to use it
  729. !  * 
  730. X   * Revision 1.5  90/03/06  16:49:14  MS_user
  731. X   * Add disable history option
  732. !  * 
  733. X   * Revision 1.4  90/03/06  15:09:27  MS_user
  734. X   * Add Unix PATH variable conversion
  735. !  * 
  736. X   * Revision 1.3  90/03/05  13:47:45  MS_user
  737. X   * Get /etc/profile and profile order rigth
  738. X   * Use $HOME/profile and not profile
  739. X   * Check cursor position before outputing prompt
  740. X   * Move some of processing in main to sub-routines
  741. !  * 
  742. X   * Revision 1.2  90/02/14  04:46:20  MS_user
  743. X   * Add Interrupt 24 processing
  744. !  * 
  745. X   * Revision 1.1  90/01/25  13:40:39  MS_user
  746. X   * Initial revision
  747. !  * 
  748. X   */
  749. X  
  750. X  #include <sys/types.h>
  751. --- 13,83 ----
  752. X   * 2.  The sources (or parts thereof) or objects generated from the sources
  753. X   *     (or parts of sources) cannot be sold under any circumstances.
  754. X   *
  755. !  *    $Header: D:/SRC/SHELL/RCS/sh1.c 1.19 90/11/06 19:13:39 Ian_Stewartson Exp $
  756. X   *
  757. X   *    $Log:    sh1.c $
  758. +  * Revision 1.19  90/11/06  19:13:39  Ian_Stewartson
  759. +  * Add deletion of swap file on interrupt
  760. +  * 
  761. +  * Revision 1.18  90/08/24  21:54:05  Ian_Stewartson
  762. +  * Add support for POSIX macro command {x#y} and {x%y}
  763. +  * 
  764. X   * Revision 1.17  90/08/14  23:32:53  MS_user
  765. X   * Fix memory bugs - Add malloc checking functions for debug
  766. X   * Make Convert_Backslashes public
  767. !  *
  768. X   * Revision 1.16  90/05/31  09:48:06  MS_user
  769. X   * Implement partial write when swapping to disk
  770. X   * Add some signal lockouts to prevent corruption
  771. !  *
  772. X   * Revision 1.15  90/05/15  21:08:59  MS_user
  773. X   * Restore original directory on exit
  774. !  *
  775. X   * Revision 1.14  90/04/25  22:33:28  MS_user
  776. X   * Fix rsh check for PATH
  777. !  *
  778. X   * Revision 1.13  90/04/25  09:18:12  MS_user
  779. X   * Change version message processing
  780. !  *
  781. X   * Revision 1.12  90/04/04  11:32:12  MS_user
  782. X   * Change MAILPATH to use a semi-colon and not a colon for DOS
  783. !  *
  784. X   * Revision 1.11  90/04/03  17:58:35  MS_user
  785. X   * Stop shell exit from lowest level CLI
  786. !  *
  787. X   * Revision 1.10  90/03/27  20:24:49  MS_user
  788. X   * Fix problem with Interrupts not restoring std??? and clearing extended file
  789. !  *
  790. X   * Revision 1.9  90/03/26  20:56:13  MS_user
  791. X   * Change I/O restore so that "exec >filename" works
  792. !  *
  793. X   * Revision 1.8  90/03/26  04:30:14  MS_user
  794. X   * Remove original Interrupt 24 save address
  795. !  *
  796. X   * Revision 1.7  90/03/12  20:16:22  MS_user
  797. X   * Save program name for Initialisation file processing
  798. !  *
  799. X   * Revision 1.6  90/03/09  16:05:33  MS_user
  800. X   * Add build file name function and change the profile check to use it
  801. !  *
  802. X   * Revision 1.5  90/03/06  16:49:14  MS_user
  803. X   * Add disable history option
  804. !  *
  805. X   * Revision 1.4  90/03/06  15:09:27  MS_user
  806. X   * Add Unix PATH variable conversion
  807. !  *
  808. X   * Revision 1.3  90/03/05  13:47:45  MS_user
  809. X   * Get /etc/profile and profile order rigth
  810. X   * Use $HOME/profile and not profile
  811. X   * Check cursor position before outputing prompt
  812. X   * Move some of processing in main to sub-routines
  813. !  *
  814. X   * Revision 1.2  90/02/14  04:46:20  MS_user
  815. X   * Add Interrupt 24 processing
  816. !  *
  817. X   * Revision 1.1  90/01/25  13:40:39  MS_user
  818. X   * Initial revision
  819. !  *
  820. X   */
  821. X  
  822. X  #include <sys/types.h>
  823. ***************
  824. *** 528,534 ****
  825. X  
  826. X      Clear_Swap_File ();
  827. X  
  828. ! /* If this is a command only - restore the directory because DOS doesn't 
  829. X   * and the user might expect it
  830. X   */
  831. X  
  832. --- 534,540 ----
  833. X  
  834. X      Clear_Swap_File ();
  835. X  
  836. ! /* If this is a command only - restore the directory because DOS doesn't
  837. X   * and the user might expect it
  838. X   */
  839. X  
  840. ***************
  841. *** 713,720 ****
  842. X      signal (SIGINT, onintr);
  843. X      SW_intr = 1;
  844. X  
  845. ! /* Are we talking to the user?  Yes - check in parser */
  846. X  
  847. X      if (talking)
  848. X      {
  849. X      if (inparse)
  850. --- 719,731 ----
  851. X      signal (SIGINT, onintr);
  852. X      SW_intr = 1;
  853. X  
  854. ! /* Zap the swap file, just in case it got corrupted */
  855. X  
  856. +     S_close (SW_fp, TRUE);
  857. +     Clear_Swap_File ();
  858. + /* Are we talking to the user?  Yes - check in parser */
  859. X      if (talking)
  860. X      {
  861. X      if (inparse)
  862. ***************
  863. *** 775,782 ****
  864. --- 786,800 ----
  865. X  register int    i;
  866. X  {
  867. X      if (i == SIGINT)        /* Need this because swapper sets it    */
  868. +     {
  869. X      SW_intr = 0;
  870. X  
  871. + /* Zap the swap file, just in case it got corrupted */
  872. +     S_close (SW_fp, TRUE);
  873. +     Clear_Swap_File ();
  874. +     }
  875. X      trapset = i;
  876. X      signal (i, sig);
  877. X  }
  878. ***************
  879. *** 1185,1298 ****
  880. X  }
  881. X  
  882. X  /*
  883. !  * Match a pattern as in sh(1).
  884. X   */
  885. X  
  886. ! bool        gmatch (s, p, IgnoreCase)
  887. ! register char    *s, *p;
  888. X  bool        IgnoreCase;
  889. X  {
  890. !     register int    sc, pc;
  891. X  
  892. !     if ((s == (char *)NULL) || (p == (char *)NULL))
  893. X      return FALSE;
  894. X  
  895. !     while ((pc = *(p++) & CMASK) != '\0')
  896. X      {
  897. !     sc = *(s++) & QMASK;
  898. X  
  899. !     switch (pc)
  900. X      {
  901. X          case '[':            /* Class expression        */
  902. !         if ((p = cclass (p, sc, IgnoreCase)) == (char *)NULL)
  903. X              return FALSE;
  904. X  
  905. X          break;
  906. X  
  907. X          case '?':            /* Match any character        */
  908. !         if (sc == 0)
  909. X              return FALSE;
  910. X  
  911. X          break;
  912. X  
  913. X          case '*':            /* Match as many as possible    */
  914. !         s--;
  915. X          do
  916. X          {
  917. !             if (!*p || gmatch (s, p, IgnoreCase))
  918. !             return TRUE;
  919. X  
  920. !         } while (*(s++));
  921. X  
  922. !         return FALSE;
  923. X  
  924. X          default:
  925. X          if (IgnoreCase)
  926. X          {
  927. !             sc = tolower (sc);
  928. !             pc = tolower ((pc & ~QUOTE));
  929. X          }
  930. X  
  931. !         if (sc != (pc & ~QUOTE))
  932. X              return FALSE;
  933. X      }
  934. X      }
  935. X  
  936. !     return (*s == 0) ? TRUE : FALSE;
  937. ! }
  938. X  
  939. X  /*
  940. X   * Process a class expression - []
  941. X   */
  942. X  
  943. ! static char    *cclass (p, sub, IgnoreCase)
  944. ! register char    *p;
  945. ! register int    sub;
  946. X  bool        IgnoreCase;
  947. X  {
  948. !     register int    c, d, not, found;
  949. X  
  950. X  /* Exclusive or inclusive class */
  951. X  
  952. !     if ((not = *p == NOT) != 0)
  953. !     p++;
  954. X  
  955. X      found = not;
  956. X  
  957. X      do
  958. X      {
  959. !     if (!*p)
  960. X          return (char *)NULL;
  961. X  
  962. X  /* Get the next character in class, converting to lower case if necessary */
  963. X  
  964. !     c = IgnoreCase ? tolower ((*p & CMASK)) : (*p & CMASK);
  965. X  
  966. X  /* If this is a range, get the end of range character */
  967. X  
  968. !     if ((*(p + 1) == '-') && (*(p + 2) != ']'))
  969. X      {
  970. !         d = IgnoreCase ? tolower ((*(p + 2) & CMASK)) : (*(p + 2) & CMASK);
  971. !         p++;
  972. X      }
  973. X  
  974. X      else
  975. !         d = c;
  976. X  
  977. X  /* Is the current character in the class? */
  978. X  
  979. !     if ((c <= sub) && (sub <= d))
  980. X          found = !not;
  981. X  
  982. !     } while (*(++p) != ']');
  983. X  
  984. !     return found ? p + 1 : (char *)NULL;
  985. X  }
  986. X  
  987. X  /*
  988. !  * Get a string in a malloced area
  989. X   */
  990. X  
  991. X  char        *getcell (nbytes)
  992. X  unsigned int    nbytes;
  993. X  {
  994. --- 1203,1381 ----
  995. X  }
  996. X  
  997. X  /*
  998. !  * Match a pattern as in sh(1).  Enhancement to handle prefix processing
  999. !  *
  1000. !  * IgnoreCase - ignore case on comparisions.
  1001. !  * end - end of match in 'string'.
  1002. !  * mode - mode for match processing - see GM_ flags in sh.h
  1003. X   */
  1004. X  
  1005. ! bool        gmatch (string, pattern, IgnoreCase, end, mode)
  1006. ! register char    *string, *pattern;
  1007. X  bool        IgnoreCase;
  1008. + char        **end;
  1009. + int        mode;
  1010. X  {
  1011. !     register int    string_c, pattern_c;
  1012. !     char        *save_end;
  1013. X  
  1014. !     if ((string == (char *)NULL) || (pattern == (char *)NULL))
  1015. X      return FALSE;
  1016. X  
  1017. !     while ((pattern_c = *(pattern++) & CMASK) != '\0')
  1018. X      {
  1019. !     string_c = *(string++) & QMASK;
  1020. X  
  1021. !     switch (pattern_c)
  1022. X      {
  1023. X          case '[':            /* Class expression        */
  1024. !         if ((pattern = cclass (pattern, string_c, IgnoreCase)) == (char *)NULL)
  1025. X              return FALSE;
  1026. X  
  1027. X          break;
  1028. X  
  1029. X          case '?':            /* Match any character        */
  1030. !         if (string_c == 0)
  1031. X              return FALSE;
  1032. X  
  1033. X          break;
  1034. X  
  1035. X          case '*':            /* Match as many as possible    */
  1036. !         --string;
  1037. !         save_end = (char *)NULL;
  1038. X          do
  1039. X          {
  1040. !             if (!*pattern ||
  1041. !             gmatch (string, pattern, IgnoreCase, end, mode))
  1042. !             {
  1043. !             if (mode == GM_LONGEST)
  1044. !                 save_end = *end;
  1045. X  
  1046. !             else
  1047. !                 return TRUE;
  1048. !             }
  1049. X  
  1050. !         } while (*(string++));
  1051. X  
  1052. +         if (end != (char **)NULL)
  1053. +             *end = save_end;
  1054. +         return (save_end == (char *)NULL) ? FALSE : TRUE;
  1055. X          default:
  1056. X          if (IgnoreCase)
  1057. X          {
  1058. !             string_c = tolower (string_c);
  1059. !             pattern_c = tolower ((pattern_c & ~QUOTE));
  1060. X          }
  1061. X  
  1062. !         if (string_c != (pattern_c & ~QUOTE))
  1063. X              return FALSE;
  1064. X      }
  1065. X      }
  1066. X  
  1067. !     if (end != (char **)NULL)
  1068. !     {
  1069. !     *end = string;
  1070. !     return TRUE;
  1071. !     }
  1072. X  
  1073. +     return (*string == 0) ? TRUE : FALSE;
  1074. + }
  1075. X  /*
  1076. X   * Process a class expression - []
  1077. X   */
  1078. X  
  1079. ! static char    *cclass (pattern, string_c, IgnoreCase)
  1080. ! register char    *pattern;
  1081. ! register int    string_c;
  1082. X  bool        IgnoreCase;
  1083. X  {
  1084. !     register int    llimit_c, ulimit_c, not, found;
  1085. X  
  1086. X  /* Exclusive or inclusive class */
  1087. X  
  1088. !     if ((not = *pattern == NOT) != 0)
  1089. !     pattern++;
  1090. X  
  1091. X      found = not;
  1092. X  
  1093. X      do
  1094. X      {
  1095. !     if (!*pattern)
  1096. X          return (char *)NULL;
  1097. X  
  1098. X  /* Get the next character in class, converting to lower case if necessary */
  1099. X  
  1100. !     llimit_c = IgnoreCase ? tolower ((*pattern & CMASK))
  1101. !                   : (*pattern & CMASK);
  1102. X  
  1103. X  /* If this is a range, get the end of range character */
  1104. X  
  1105. !     if ((*(pattern + 1) == '-') && (*(pattern + 2) != ']'))
  1106. X      {
  1107. !         ulimit_c = IgnoreCase ? tolower ((*(pattern + 2) & CMASK))
  1108. !                   : (*(pattern + 2) & CMASK);
  1109. !         pattern++;
  1110. X      }
  1111. X  
  1112. X      else
  1113. !         ulimit_c = llimit_c;
  1114. X  
  1115. X  /* Is the current character in the class? */
  1116. X  
  1117. !     if ((llimit_c <= string_c) && (string_c <= ulimit_c))
  1118. X          found = !not;
  1119. X  
  1120. !     } while (*(++pattern) != ']');
  1121. X  
  1122. !     return found ? pattern + 1 : (char *)NULL;
  1123. X  }
  1124. X  
  1125. X  /*
  1126. !  * Suffix processing - find the longest/shortest suffix.
  1127. X   */
  1128. X  
  1129. + bool        gmatch_suffix (string, pattern, IgnoreCase, start, mode)
  1130. + register char    *string, *pattern;
  1131. + bool        IgnoreCase;
  1132. + char        **start;
  1133. + int        mode;
  1134. + {
  1135. +     char    *save_start = (char *)NULL;
  1136. + /* Scan the string, looking for a match to the end */
  1137. +     while (*string)
  1138. +     {
  1139. +     if (gmatch (string, pattern, IgnoreCase, (char **)NULL, GM_ALL))
  1140. +     {
  1141. + /* If longest, stop here */
  1142. +         if (mode == GM_LONGEST)
  1143. +         {
  1144. +         *start = string;
  1145. +         return TRUE;
  1146. +         }
  1147. + /* Save the start of the shortest string so far and continue */
  1148. +         save_start = string;
  1149. +     }
  1150. +     ++string;
  1151. +     }
  1152. +     return ((*start = save_start) == (char *)NULL) ? FALSE : TRUE;
  1153. + }
  1154. + /*
  1155. +  * Get a string in a malloced area
  1156. +  */
  1157. X  char        *getcell (nbytes)
  1158. X  unsigned int    nbytes;
  1159. X  {
  1160. ***************
  1161. *** 1323,1329 ****
  1162. X      print_warn ("Malloc access to bad segment\n");
  1163. X      return (char *)NULL;
  1164. X      }
  1165. !     
  1166. X      np->magic1             = MAGIC1;
  1167. X      np->len               = nbytes;
  1168. X      rp                          = (char *)(np + 1);
  1169. --- 1406,1412 ----
  1170. X      print_warn ("Malloc access to bad segment\n");
  1171. X      return (char *)NULL;
  1172. X      }
  1173. X      np->magic1             = MAGIC1;
  1174. X      np->len               = nbytes;
  1175. X      rp                          = (char *)(np + 1);
  1176. ***************
  1177. *** 1362,1370 ****
  1178. X  /* Disable signals */
  1179. X  
  1180. X      save_signal = signal (SIGINT, SIG_IGN);
  1181. -     
  1182. - /* Find the string in the chain */
  1183. X  
  1184. X      if (s != (char *)NULL)
  1185. X      {
  1186. X      while (cp != (s_region *)NULL)
  1187. --- 1445,1453 ----
  1188. X  /* Disable signals */
  1189. X  
  1190. X      save_signal = signal (SIGINT, SIG_IGN);
  1191. X  
  1192. + /* Find the string in the chain */
  1193. X      if (s != (char *)NULL)
  1194. X      {
  1195. X      while (cp != (s_region *)NULL)
  1196. ***************
  1197. *** 2012,2018 ****
  1198. X      str1++;
  1199. X      str2++;
  1200. X      }
  1201. !     
  1202. X      return rtn;
  1203. X  }
  1204. X  
  1205. --- 2095,2101 ----
  1206. X      str1++;
  1207. X      str2++;
  1208. X      }
  1209. X      return rtn;
  1210. X  }
  1211. X  
  1212. ***************
  1213. *** 2064,2074 ****
  1214. X  
  1215. X      while (--len >= 0)
  1216. X      {
  1217. !     if ((*(str1++) = *(str2++)) == 0)    
  1218. X      {
  1219. X          while (--len >= 0)
  1220. X          *(str1++) = 0;
  1221. !         
  1222. X          break;
  1223. X      }
  1224. X      }
  1225. --- 2147,2157 ----
  1226. X  
  1227. X      while (--len >= 0)
  1228. X      {
  1229. !     if ((*(str1++) = *(str2++)) == 0)
  1230. X      {
  1231. X          while (--len >= 0)
  1232. X          *(str1++) = 0;
  1233. X          break;
  1234. X      }
  1235. X      }
  1236. Index: shell/sh3.c
  1237. Prereq: 1.24
  1238. *** ../sh16.3/shell/sh3.c    Fri Aug 17 21:34:34 1990
  1239. --- shell/sh3.c    Tue Nov  6 19:21:26 1990
  1240. ***************
  1241. *** 13,21 ****
  1242. X   * 2.  The sources (or parts thereof) or objects generated from the sources
  1243. X   *     (or parts of sources) cannot be sold under any circumstances.
  1244. X   *
  1245. !  *    $Header: C:/SRC/SHELL/RCS/sh3.c 1.24 90/08/16 10:28:47 Ian_Stewartson Exp $
  1246. X   *
  1247. X   *    $Log:    sh3.c $
  1248. X   * Revision 1.24  90/08/16  10:28:47  Ian_Stewartson
  1249. X   * Find setting of switch character for DOS4 for batch files
  1250. X   * 
  1251. --- 13,32 ----
  1252. X   * 2.  The sources (or parts thereof) or objects generated from the sources
  1253. X   *     (or parts of sources) cannot be sold under any circumstances.
  1254. X   *
  1255. !  *    $Header: C:/SRC/SHELL/RCS/sh3.c 1.27 90/09/19 15:30:31 Ian_Stewartson Exp $
  1256. X   *
  1257. X   *    $Log:    sh3.c $
  1258. +  * Revision 1.27  90/09/19  15:30:31  Ian_Stewartson
  1259. +  * Allow builtin commands to selected/de-selected
  1260. +  * 
  1261. +  * Revision 1.26  90/09/11  20:06:11  Ian_Stewartson
  1262. +  * Add support for buitlin command, including the alway builtin functions
  1263. +  * Change search order to match POSIX
  1264. +  * 
  1265. +  * Revision 1.25  90/08/24  21:55:00  Ian_Stewartson
  1266. +  * Change processing order (function, external, internal) to conform to
  1267. +  * POSIX.  Update to gmatch for macro command changes
  1268. +  * 
  1269. X   * Revision 1.24  90/08/16  10:28:47  Ian_Stewartson
  1270. X   * Find setting of switch character for DOS4 for batch files
  1271. X   * 
  1272. ***************
  1273. *** 144,149 ****
  1274. --- 155,161 ----
  1275. X  static char    *AE2big = "arg/env list too big";
  1276. X  static char    *EMS_emsg = "Warning: EMS Error (%x)\n";
  1277. X  static char    *XMS_emsg = "Warning: XMS Error (%x)\n";
  1278. + static char    *EF_msg = "%s: %s\n";
  1279. X              /* Extended Command line processing file name    */
  1280. X  static char        *Extend_file = (char *)NULL;
  1281. X  static char        *Swap_File = (char *)NULL;    /* Swap file    */
  1282. ***************
  1283. *** 475,481 ****
  1284. --- 487,495 ----
  1285. X      void    (*sig_int)();
  1286. X      char    **owp = wp;
  1287. X      bool    spawn = FALSE;
  1288. +     bool    builtin = FALSE;
  1289. X      Fun_Ops    *fop;
  1290. +     int        i;
  1291. X  
  1292. X      if (t->type == TCOM)
  1293. X      {
  1294. ***************
  1295. *** 510,522 ****
  1296. X  /* Check for built in commands */
  1297. X  
  1298. X      else if (cp != (char *)NULL)
  1299. !         shcom = inbuilt (cp);
  1300. X      }
  1301. X  
  1302. X  /* Unix fork simulation? */
  1303. X  
  1304. X      t->words = wp;
  1305. !     if (shcom == NULL && (act & FEXEC) == 0)
  1306. X      {
  1307. X      spawn = TRUE;
  1308. X  
  1309. --- 524,536 ----
  1310. X  /* Check for built in commands */
  1311. X  
  1312. X      else if (cp != (char *)NULL)
  1313. !         shcom = inbuilt (cp, &builtin);
  1314. X      }
  1315. X  
  1316. X  /* Unix fork simulation? */
  1317. X  
  1318. X      t->words = wp;
  1319. !     if ((act & FEXEC) == 0)
  1320. X      {
  1321. X      spawn = TRUE;
  1322. X  
  1323. ***************
  1324. *** 534,540 ****
  1325. X  
  1326. X      while (((cp = *owp++) != (char *)NULL) && assign (cp, COPYV))
  1327. X      {
  1328. !     if (shcom == NULL)
  1329. X          s_vstatus (lookup (cp, TRUE), EXPORT);
  1330. X      }
  1331. X  
  1332. --- 548,554 ----
  1333. X  
  1334. X      while (((cp = *owp++) != (char *)NULL) && assign (cp, COPYV))
  1335. X      {
  1336. !     if (shcom == (int (*)())NULL) 
  1337. X          s_vstatus (lookup (cp, TRUE), EXPORT);
  1338. X      }
  1339. X  
  1340. ***************
  1341. *** 565,572 ****
  1342. X      }
  1343. X      }
  1344. X  
  1345. -     if (shcom)
  1346. -     return restore_std (setstatus ((*shcom)(t)), TRUE);
  1347. X  
  1348. X  /* All fids above 10 are autoclosed in the exec file because we have used
  1349. X   * the O_NOINHERIT flag.  Note I patched open.obj to pass this flag to the
  1350. --- 579,584 ----
  1351. ***************
  1352. *** 598,604 ****
  1353. X   * in some processing for return.
  1354. X   */
  1355. X  
  1356. !     if ((fop = Fun_Search (wp[0])) != (Fun_Ops *)NULL)
  1357. X      {
  1358. X      char            **s_dolv = dolv;
  1359. X      int            s_dolc   = dolc;
  1360. --- 610,616 ----
  1361. X   * in some processing for return.
  1362. X   */
  1363. X  
  1364. !     if (!builtin && (fop = Fun_Search (wp[0])) != (Fun_Ops *)NULL)
  1365. X      {
  1366. X      char            **s_dolv = dolv;
  1367. X      int            s_dolc   = dolc;
  1368. ***************
  1369. *** 651,659 ****
  1370. X  
  1371. X  /* Ok - execute the program */
  1372. X  
  1373. !     return restore_std (rexecve (wp[0], wp, makenv (), spawn), TRUE);
  1374. ! }
  1375. X  
  1376. X  /*
  1377. X   * Restore Local Environment
  1378. X   */
  1379. --- 663,685 ----
  1380. X  
  1381. X  /* Ok - execute the program */
  1382. X  
  1383. !     if (!builtin)
  1384. !     rv = rexecve (wp[0], wp, makenv (), spawn);
  1385. X  
  1386. + /* If we didn't find it, check for internal command */
  1387. +     if (builtin || ((rv == -1) && (errno == ENOENT)))
  1388. +     {
  1389. +     if (shcom != (int (*)())NULL) 
  1390. +         rv =  setstatus ((*shcom)(t));
  1391. +     else
  1392. +         print_warn (EF_msg, wp[0], "not found");
  1393. +     }
  1394. +     return restore_std (rv, TRUE);
  1395. + }
  1396. X  /*
  1397. X   * Restore Local Environment
  1398. X   */
  1399. ***************
  1400. *** 835,841 ****
  1401. X  
  1402. X      for (wp = t1->words; *wp != (char *)NULL;)
  1403. SHAR_EOF
  1404. true || echo 'restore of Patch1.6.4 failed'
  1405. fi
  1406. echo 'End of  part 1'
  1407. echo 'File Patch1.6.4 is continued in part 2'
  1408. echo 2 > _shar_seq_.tmp
  1409. exit 0
  1410.  
  1411. exit 0 # Just in case...
  1412. -- 
  1413. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  1414. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  1415. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  1416. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  1417.